package com.Thread;

import java.util.concurrent.*;

/**
 * @author: sun.hongliang
 * @create: 2019/06/25 11:34
 */
public class ExecutorTest {
    public static void main(String[] args) throws Exception {
        Callable<String> callable = new Callable<String>() {
            @Override
            public String call() throws Exception {
                TimeUnit.SECONDS.sleep(10);
                return "a";
            }
        };
        final FutureTask<String> target = new FutureTask<String>(callable);
        final Thread thread = new Thread(target);
        thread.start();
        System.out.println(target.get());
        final ExecutorService executorService = Executors.newFixedThreadPool(1);
        final ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(5, 5, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
        poolExecutor.allowCoreThreadTimeOut(true);
        poolExecutor.execute(()->{});
        Executors.newFixedThreadPool(100);
        Executors.newCachedThreadPool();
    }
}
